using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

using System.Text;
using System.Windows.Forms;

namespace Mud.Client.WinApplication
{
    public partial class frmChooseCharacter : Form
    {

        public Creature Selected
        {
            get { return _selected; }
        }
        private Creature _selected;

        private IList<Creature> _characters;

        public frmChooseCharacter(IList<Creature> characters)
        {
            InitializeComponent();
            _characters = characters;
            foreach (Creature creature in _characters)
            {
                ListViewItem lvItem = new ListViewItem(new string[] { creature.Name, creature.CurrentAreaName});
                lvCharacters.Items.Add(lvItem);
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if(lvCharacters.SelectedItems.Count == 0)
                return;

            foreach (Creature creature in _characters)
                if (creature.Name == lvCharacters.SelectedItems[0].Text)
                    _selected = creature;

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}